#include <iostream>
using namespace std;

int main() {
    int n, q;
    cin >> n >> q;
    long long* arr = new long long[n + 1], * dp = new long long[n + 1];
    arr[0] = 0, dp[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
        dp[i] = dp[i - 1] + arr[i];
    }
    while (q--) {
        int l, r;
        cin >> l >> r;
        cout << dp[r] - dp[l - 1] << endl;
    }
    delete[] arr;
    delete[] dp;
    return 0;
}